//
//  GoldView.swift
//  WalkNovel
//
//  Created by Kevin on 2023/8/28.
//

import UIKit

class GoldView: UIView {
    
    lazy var recodBtn: UIButton = {
        let btn = UIButton(type: .custom)
        btn.setTitle("中獎記錄", for: .normal)
        btn.setTitleColor(.init(named: "red_FE95B4"), for: .normal)
        btn.titleLabel?.font = .wn_font(name: .bold, size: 16)
        btn.setImage(UIImage(named: "reward_arrow"), for: .normal)
        btn.rx.tap.bind { [weak self] in
            self?.viewContainingController?.navigationController?.pushViewController(WNDrawRecordVC(), animated: true)
        }.disposed(by: rx.disposeBag)
        return btn
    }()
    
    lazy var goldImage: UIImageView = {
        let image = UIImageView(image: UIImage(named: "reward_coin"))
        return image
    }()
    
    lazy var goldCount: UILabel = {
        let label = UILabel()
        label.font = .wn_font(name: .bold, size: 14)
        label.textColor = .black
        return label
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .white
        addSubview(goldImage)
        addSubview(goldCount)
        addSubview(recodBtn)
        goldImage.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(6)
            make.width.height.equalTo(32)
        }
        goldCount.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(goldImage.snp.right).offset(6)
        }
        recodBtn.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalTo(-6)
        }
        recodBtn.layoutButton(style: .right, imageTitleSpace: 0)
        wn_cornerWithBorder(20)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
